﻿using AutoMapper;
using StudentManagementSystem.Entities;
using StudentManagementSystem.Dtos;

namespace StudentManagementSystem.Profiles
{
    public class EmplyeeProfile : Profile
    {
        public EmplyeeProfile()
        {
            CreateMap<Employee, EmployeeDto>()
                .ForMember(dest => dest.Name,
                opt => opt.MapFrom(src => $"{src.FirstName}-{src.LastName}"))
                .ForMember(dest => dest.GenderDisplay,
                opt => opt.MapFrom(src => src.Gender.ToString()))
                .ForMember(dest => dest.Age,
                opt => opt.MapFrom(src => DateTime.Now.Year - src.DateOfBirth.Year));

            CreateMap<EmployeeAddDto, Employee>();
        }
    }
}
